<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:LJQ <liujiqi@etrol.com>
// +-----------------------------------------------------------------------

namespace app\rehearse\model;

use app\common\model\Base;
use app\basic\model\Unit;
/**
 * 救援行动步骤管理
 */
class Recorddetail extends Base{
	protected $name = 'actionstep';
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';

	public $recorddetailTypeList=[] ;

	public  function getType(){

		$recorddetailType=db('basicinfo')->where(array('sysCode'=>25))->column('subsystemName','subsystemNo');
		$this->recorddetailTypeList=$recorddetailType;
		return $this->recorddetailTypeList;
	}


	public function getActionIdAttr($value,$data){
		$this->getType();
		if($data['actionId']){
			return $this->recorddetailTypeList[$data['actionId']];
		}
		return null;
	}


	public function getImplementTimeAttr($value,$data){
		if($data['implementTime']){
			return date('Y-m-d H:i:s',$data['implementTime']);
		}
	}

	public function setImplementTimeAttr($value,$data){
			if($value==null){
				return time();
			}
			return strtotime($value);
	}

	public function setFinishTimeAttr($value,$data){
		return strtotime($value);
	}


	public function getFinishTimeAttr($value,$data){
		if($data['finishTime']){
			return date('Y-m-d H:i:s',$data['finishTime']);
		}
	}

	public  function  unit(){
		return $this->hasOne(Unit::class,'id','chargePerson');
	}

	}


